package uk.ac.glasgow.demosocs.users;

/**
 * The Class User represents a User of the Voting System.
 * 
 * @author Project Team L
 */
public class User {

	/** The surname. */
	private String surname;

	/** The forename. */
	private String forename;

	/** The GUID. */
	private String GUID;

	/** The password. */
	private String password;

	/** The voter. */
	private boolean voter = false;

	/** The nominee. */
	private boolean nominee = false;

	/** The candidate. */
	private boolean candidate = false;

	/** The manager. */
	private boolean manager = false;


	/**
	 * Instantiates a new user.
	 *
	 * @param surname the surname
	 * @param forename the forename
	 * @param GUID the gUID
	 * @param password the password
	 */
	public User (String surname, String forename, String GUID, String password){
		this.surname = surname;
		this.forename = forename;
		this.GUID = GUID;
		this.password = password;
	}

	/**
	 * Instantiates a new user.
	 *
	 * @param user the user
	 */
	public User(User user){
		this.surname = user.getSurname();
		this.forename = user.getForename();
		this.GUID = user.getGUID();
		this.password = user.getPassword();
	}

	/**
	 * Authenticate.
	 *
	 * @param password the password
	 * @return true, if successful
	 */
	protected boolean authenticate (String password){
		return this.password.equals(password);
	}


	/**
	 * Gets the surname.
	 *
	 * @return the surname
	 */
	public String getSurname() {
		return surname;
	}

	/**
	 * Sets the surname.
	 *
	 * @param surname the new surname
	 */
	public void setSurname(String surname) {
		this.surname = surname;
	}

	/**
	 * Gets the forename.
	 *
	 * @return the forename
	 */
	public String getForename() {
		return forename;
	}

	/**
	 * Sets the forename.
	 *
	 * @param forename the new forename
	 */
	public void setForename(String forename) {
		this.forename = forename;
	}

	/**
	 * Gets the gUID.
	 *
	 * @return the gUID
	 */
	public String getGUID(){
		return GUID;
	}

	/**
	 * Sets the gUID.
	 *
	 * @param gUID the new gUID
	 */
	public void setGUID(String gUID) {
		GUID = gUID;
	}

	/**
	 * Gets the password.
	 *
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Sets the password.
	 *
	 * @param password the new password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Checks if is election manager.
	 *
	 * @return true, if is election manager
	 */
	public boolean isElectionManager(){
		return this.manager;
	}

	/**
	 * Checks if is voter.
	 *
	 * @return true, if is voter
	 */
	public boolean isVoter(){
		return this.voter;
	}

	/**
	 * Checks if is candidate.
	 *
	 * @return true, if is candidate
	 */
	public boolean isCandidate(){
		return this.candidate;
	}

	/**
	 * Checks if is nominee.
	 *
	 * @return true, if is nominee
	 */
	public boolean isNominee(){
		return this.nominee;
	}

	/**
	 * Make manager.
	 */
	public void makeManager(){
		this.manager = true;
	}

	/**
	 * Make voter.
	 */
	public void makeVoter(){
		this.voter = true;
	}

	/**
	 * Make candidate.
	 */
	public void makeCandidate(){
		this.candidate = true;
	}

	/**
	 * Make nominee.
	 */
	public void makeNominee(){
		this.nominee = true;
	}

	/**
	 * Returns a Strign representation of this User (used for testing purposes).
	 * 
	 * @return String containing full name GUID and password
	 */
	public String toString(){
		return surname + " " + forename + " " + GUID + " " + password;
	}

}
